  
     var swiper = new Swiper(".mySwiper", {
      	//slidesPerView : 2,//一页里面放两个
      	//自动轮播
      	autoplay:true,
      	//无限循环
      	loop:true,
      	//分页器
        pagination: {
          el: ".swiper-pagination",
          clickable:true,//是否能点击
        },
        navigation: {
      		nextEl: '.swiper-button-next',
      		prevEl: '.swiper-button-prev',
    	  },
      });


let navsecond = document.querySelector('.nav-second-body')
ajax({
  method: "get",
  url: "stage-api/website/getProductMenuInfo",
  success: function(res){
    console.log(res)
    for (let i = 0; i < res.data.length; i++) {
      if (i == 4) {
        continue;
      }else if(i == 6){
        continue;
      }else{
         navsecond.innerHTML += `<li class="nav-second-item" onclick="detail('${res.data[i].productId}')">
                                <div class="navsec-bod">
                                  <img src="${res.data[i].menuIcon.split("?")[0]}">
                                  <div>${res.data[i].productName}</div>
                                </div>
                              </li>`
      }
     
    }
  }
})



let productBody = document.querySelector('.product-body')
let xhr = new XMLHttpRequest()
xhr.open("get", "stage-api/website/getHomePageInfo")
xhr.send()
xhr.onreadystatechange = function(){
  if (xhr.readyState == 4){
    let res = JSON.parse(xhr.responseText)
    console.log(res)
    if (res.code == 200) {
      // productImg.src = `${res.data.products[0].logoPhotoAddress}.split("?")[0]`
      for (let i = 0; i < res.data.products.length; i++) {
          productBody.innerHTML += `<div class="product-item" onclick="detail('${res.data.products[i].productId}')">
                                        <div class="product-img">
                                          <img src="${res.data.products[i].logoPhotoAddress}.split("?")[0]">
                                        </div>
                                        <div class="product-text">
                                          <span class="product-text-up">${res.data.products[i].productName}</span><br>
                                          <span class="product-text-down">${res.data.products[i].productName}</span>
                                        </div>
                                      </div>`
      }
    }
  }
}


let newTt = document.querySelectorAll('.new-text-top')
let newTul = document.querySelectorAll('.newtext-list')
ajax({
  method: 'get',
  url: "stage-api/website/getNewsList",
  params: {
    pageNum: 1,
    pageSize: 4,
    newsType: 1
  },
  success: function(res) {
    console.log(res)
    newTt[0].innerHTML += `<div class="newtext-top-left" onclick="newsmore1('${res.rows[0].newsId}')">
                          <img src="${res.rows[0].newsPic}">
                        </div>
                        <div class="newtext-top-right" onclick="newsmore1('${res.rows[0].newsId}')">
                          <div class="newtextR-title">${res.rows[0].newsName}</div>
                          <div class="newtextR-text">${res.rows[0].remark}</div>
                          <div class="newtextR-tool">
                            <div class="toolL">查看详情</div>
                            <div class="toolR">2022-07-12</div>
                          </div>
                        </div>`
    for (let i = 1; i < res.rows.length; i++) {
      newTul[0].innerHTML += `<li class="newtextL" onclick="newsmore1('${res.rows[i].newsId}')">
                              <span class="dot"></span>
                              <span class="text">${res.rows[i].newsName}</span>
                              <span class="time">${res.rows[i].createTime.split(" ")[0]}</span>
                            </li>`
    }
  }
})

function newsmore1(newsId) {
  location.href = `newsmore1.html?newsId=${newsId}`
}

ajax({
  method: 'get',
  url: "stage-api/website/getNewsList",
  params: {
    pageNum: 1,
    pageSize: 4,
    newsType: 2
  },
  success: function(res) {
    console.log(res)
    newTt[1].innerHTML += `<div class="newtext-top-left" onclick="newsmore2('${res.rows[0].newsId}')">
                          <img src="${res.rows[0].newsPic}">
                        </div>
                        <div class="newtext-top-right" onclick="newsmore1('${res.rows[0].newsId}')">
                          <div class="newtextR-title">${res.rows[0].newsName}</div>
                          <div class="newtextR-text">${res.rows[0].remark}</div>
                          <div class="newtextR-tool">
                            <div class="toolL">查看详情</div>
                            <div class="toolR">2022-07-12</div>
                          </div>
                        </div>`
    for (let i = 1; i < res.rows.length; i++) {
      newTul[1].innerHTML += `<li class="newtextL" onclick="newsmore2('${res.rows[i].newsId}')">
                              <span class="dot"></span>
                              <span class="text">${res.rows[i].newsName}</span>
                              <span class="time">${res.rows[i].createTime.split(" ")[0]}</span>
                            </li>`
    }
  }
})

function newsmore2(newsId) {
  location.href = `newsmore2.html?newsId=${newsId}`
}

let newlist = document.querySelectorAll('.new-list-top')
let newText = document.querySelectorAll('.new-text')
for (var i = 0; i < newlist.length; i++) {
      //给每一个span造一个下标
      newlist[i].index = i
      //给每一个span添加一个点击事件
      newlist[i].onclick = function(){
        //先获取到原来有active类名的给他清空
        document.querySelector('.liston').className = 'new-list-top'
        document.querySelector('.action').className = 'new-text'
        this.className = 'new-list-top liston'
        newText[this.index].className = 'new-text action'
      } 
    }

    let solutionimg = document.querySelector('.solution-body .mySwiper2 .swiper-wrapper')
    ajax({
      method: "get",
      url: "stage-api/website/getHomePageInfo",
      success: function(res){
        console.log(res)
        for (let i = 0; i < res.data.solutions.length; i++){
          solutionimg.innerHTML += `<div class="swiper-slide"  onclick="solutdetail('${res.data.solutions[i].solutionId}')">
                                      <img src="${res.data.solutions[i].solutionPhotoAddress.split("?")[0]}">
                                    </div>`
        }
        var swiper2 = new Swiper(".mySwiper2", {
            slidesPerView: 5,
            spaceBetween: 10,
            slidesPerGroup: 5,
            loop: true,
            loopFillGroupWithBlank: true,
            pagination: {
              el: ".swiper-pagination",
              clickable: true,
            },
          });
      }
    })

    function solutdetail(solutionId) {
  location.href = `solutionshow.html?solutionId=${solutionId}`
}

    let casebody = document.querySelector(".case-body")
    ajax({
      method: "get",
      url: "stage-api/website/getHomePageInfo",
      success: function(res) {
        console.log(res)
        for (let i = 0; i < 4; i++) {
          casebody.innerHTML += `<div class="case-item" onclick="casedetails('${res.data.companyInfo[i].caseCompanyId}')">
                                    <div class="caseitem-img">
                                      <img src="${res.data.companyInfo[i].companyLogoPhoto.split("?")[0]}">
                                    </div>
                                    <div class="caseitem-font">
                                      <div class="caseitem-font-title">
                                      ${res.data.companyInfo[i].caseCompanyName}
                                        <div class="caseitem-ly"></div>
                                      </div>
                                      <div class="caseitem-font-text">${res.data.companyInfo[i].remark}</div>
                                      <div class="caseitem-font-time">${res.data.companyInfo[i].updateTime.split(" ")[0]}</div>
                                    </div>
                                  </div>`
        }
      }
    })

    function casedetails(caseCompanyId) {
  location.href = `casestudyshow.html?caseCompanyId=${caseCompanyId}`
}

    let corimg = document.querySelector('.cor-body')
    ajax({
      method: "get",
      url: "stage-api/website/coo/list",
      success: function(res){
        console.log(res)
        for (let i = 0; i < res.rows.length; i++) {
          corimg.innerHTML += `<div class="cor-item">
                                  <div class="coritem-body">
                                    <div class="coritem-img">
                                      <img src="${res.rows[i].logoUrl}">
                                    </div>
                                  </div>
                                </div>`
        }
      }
    })

    //跳转
    function detail(productId) {
      location.href = `product.html?productId=${productId}`
    }

    function News(newsType){
  location.href = `newscenter.html?newsType=${newsType}`
}